﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKCoordinate;

namespace YJKRevitPipeSetting.Utiltiy
{
	internal class PipeInputChecker : PipeIChecker
	{
		public bool PipeIfCanUse(List<XYZ> inputPoints, CornerKindEnum cornerKindEnum, Dictionary<PipeUseParameterEnum, double> inputValues)
		{
			double num = inputValues[PipeUseParameterEnum.Width];
			switch (cornerKindEnum)
			{
			case CornerKindEnum.SingleChamfer:
				num = Math.Max(num, inputValues[PipeUseParameterEnum.Height]);
				break;
			case CornerKindEnum.Chamfer:
				num = Math.Max(num, inputValues[PipeUseParameterEnum.Height]);
				break;
			}
			num = this.coff * num;
			num = Math.Abs(num);
			return this.PipeIfCanUse(inputPoints, num);
		}

		private bool PipeIfCanUse(List<XYZ> inputPoints, double inputValues)
		{
			for (int i = 0; i < inputPoints.Count; i++)
			{
				for (int j = i; j < inputPoints.Count; j++)
				{
					if (i != j && inputPoints[i].DistanceTo(inputPoints[j]) < inputValues)
					{
						return false;
					}
				}
			}
			return true;
		}

		private double coff = 1.2;
	}
}
